import 'package:flutter/material.dart';
import '../Constants/constants.dart' show AppColors;
import '../Constants/constants.dart';
import '../Constants/styles/app_style.dart';

class ContactItemLay extends StatelessWidget {
  final String iconPath;
  final String title;
  final String hasGroupTitle;
  final bool hasDivider;
  final VoidCallback pressed;
  List<Widget> _layoutsVertiaclInner;
  List<Widget> _layoutsVertiaclOuter;
  List<Widget> _layoutsRow;

  ContactItemLay(
      {@required this.iconPath,
      @required this.title,
      //@required this.hasBottom,
      this.hasGroupTitle: null,
      this.hasDivider: false,
      @required this.pressed});

  @override
  Widget build(BuildContext context) {
    _layoutsRow = [
              SizedBox(width:Constants.Wh * 43),
              ClipRRect(
                borderRadius: BorderRadius.circular(Constants.Wh*14), 
                child:Image.asset(this.iconPath,
                  width: Constants.Wh * 108, height: Constants.Wh * 108)),
              SizedBox(width:Constants.Wh * 45),
              Container(
                child: Text(this.title,
                    style:TextStyleNw.listItemMain,)
              ),
    ];
   
    _layoutsVertiaclInner = [
      Container(         
          padding: EdgeInsets.only(top: Constants.Hh * 22, bottom: Constants.Hh * 22),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: _layoutsRow
          ))
    ];
 
    //如果带下划线
    if (this.hasDivider == true) {
         _layoutsVertiaclInner.add(Container(
        color:Color(AppColors.WhiteColor),
       padding:EdgeInsets.only(left:Constants.Wh*202),
      child: Divider(height: 1,color: Color(AppColors.SpliteLineColor),),
       ));
    }
    
    var btn = FlatButton (
      padding: EdgeInsets.only(left:0),
      shape: RoundedRectangleBorder(
           side: BorderSide(width: 0, color: Colors.transparent)),

      color:Colors.white,
      onPressed: this.pressed,
      child: Column(
          crossAxisAlignment: CrossAxisAlignment.start, children: _layoutsVertiaclInner),
    );
     
    _layoutsVertiaclOuter = [btn]; 
    //如果带分组标题
    if(this.hasGroupTitle != null) {
      _layoutsVertiaclOuter.insert(0,  Container(
         width: double.infinity,
        decoration: BoxDecoration(border:Border(top:BorderSide(color: Color(AppColors.SpliteLineColor),width:1),
        bottom:BorderSide(color: Color(AppColors.SpliteLineColor),width:1)),color: Colors.transparent),
        padding:EdgeInsets.only(left:Constants.Wh*45,top: Constants.Hh*21,bottom: Constants.Hh*21),
        child: Text(this.hasGroupTitle,style: TextStyleNw.groupTitle,)));
    }
    

    return Column (
      children: _layoutsVertiaclOuter,
    );
  }
}
